package com.leetcode.Offer;

public class JZ28 {

    public boolean isSymmetric(TreeNode root) {
        return isSymmetry(root, root);
    }

    private boolean isSymmetry(TreeNode root1, TreeNode root2) {
        if (root1 == null && root2 == null) {
            return true;
        }
        if (root1 == null || root2 == null) {
            return false;
        }
        if (root1.val != root2.val) {
            return false;
        }

        return isSymmetry(root1.left, root2.right) && isSymmetry(root1.right, root2.left);
    }

}
